package com.masterclient.app.base;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.masterclient.app.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：sean
 * 创建时间：2017/8/28 13:35
 * 功能说明：
 */

public class ProgressLoginDialog extends Dialog {
    @BindView(R.id.progress)
    ProgressBar progress;
    @BindView(R.id.progress_desc)
    TextView progressDesc;

    public ProgressLoginDialog(@NonNull Context context) {
        super(context, R.style.progress_dialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_progress_login);
        ButterKnife.bind(this);
        setCanceledOnTouchOutside(false);
    }

    public void setDesc(String str){
        if (TextUtils.isEmpty(str)){
            progressDesc.setVisibility(View.GONE);
        }else {
            progressDesc.setText(str);
        }
    }


    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowparams = window.getAttributes();
        window.setGravity(Gravity.CENTER);
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowparams);
    }
}
